added SSCLI 1.0
[windows-sources.git] / sdk / samples / all in on code / Visual Studio 2008 / CSWinFormPassValueBetweenForms / ReadMe.txt
blob59f0ffd5ccf4b26f21b0f50534c9193345925ff2
1 ================================================================================
2        WINDOWS FORMS APPLICATION : CSWinFormPassValueBetweenForms Project Overview
3        
4                         Pass Value Between Forms Sample
5                         
6 ===============================================================================
8 /////////////////////////////////////////////////////////////////////////////
9 Use:
11 The Pass Value Between Forms sample demonstrates how to pass value between forms.
13 There're two common ways to pass value between forms:
15 1. Use a property.
17    Create a public property on the target form class, then we can pass value 
18    to the target form by setting value for the property.
20 2. Use a method.
22    Create a public method on the target form class, then we can pass value to 
23    the target form by passing the value as parameter to the method.
24    
26 /////////////////////////////////////////////////////////////////////////////
27 Code Logic:
29    1. Create two forms named FrmPassValueBetweenForms and 
30       FrmPassValueBetweenForms2 respectively;
31       
32    2. Create a public property named ValueToPassBetweenForms in the 
33       FrmPassValueBetweenForms2 class;
34       
35       private string _valueToPassBetweenForms;
37       public string ValueToPassBetweenForms
38       {
39           get { return this._valueToPassBetweenForms; }
40           set { this._valueToPassBetweenForms = value; }
41       }
43       
44    3. Create a public method named SetValueFromAnotherForm in the 
45       FrmPassValueBetweenForms2 class;
46       
47       public void SetValueFromAnotherForm(string val)
48       {
49           this._valueToPassBetweenForms = val;
50       }
51       
52    4. On the FrmPassValueBetweenForms form, handle the Click event of the buttons.
53       In the Click event handler of button1, set the SetValueFromAnotherForm 
54       property for the FrmPassValueBetweenForms2 to pass the text value from 
55       FrmPassValueBetweenForms to FrmPassValueBetweenForms2.
56       In the Click event handler of button2, call the SetValueFromAnotherForm 
57       method and pass the text value as parameter to the FrmPassValueBetweenForms2.
60 /////////////////////////////////////////////////////////////////////////////
61 References:
62    
63 1. Windows Forms General FAQ.
64    http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/77a66f05-804e-4d58-8214-0c32d8f43191
65    
67 /////////////////////////////////////////////////////////////////////////////